package pratice.learn.flow;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.RuntimeService;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

/**
 * 学习流程定义
 * @author 吴宇亮 on 2019/5/14 0014 下午 3:50
 */
public class ProcessInstantce {

    public static ProcessEngine processEngine = ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault().buildProcessEngine();

    @Test
    public void startProcess(){
        RuntimeService runtimeService = processEngine.getRuntimeService();
        Map<String, Object> variables = new HashMap<>(); //用来决定流程的走向

//        runtimeService.startProcessInstanceById("id");
        runtimeService.startProcessInstanceById("id", "businessKey"); //用流程定义id和业务id启动流程，把流程执行实例与业务id做绑定
        runtimeService.startProcessInstanceById("id", variables); //传流程定义id和流程变量启动流程
        runtimeService.startProcessInstanceById("id", "key", variables);

        //id和key都是一样的，实际开发中会使用key去启动
//        runtimeService.startProcessInstanceByKey();
    }
}






















